package com.neu.icloud.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.neu.icloud.entity.Product;

@Mapper
public interface ProductMapper {

//	@Select("select * from product where factoryId=#{factoryId}")
	@Select("select * from product ")
	public List<Product> allListProduct(Product product);
	
//	产品列表
	public List<Product> listProduct(Integer productId);
	
	//根据工厂id查询所有产品
	@Select("select * from product where factoryId=#{factoryId}")
	public List<Product> findAllProductByFactoryId(Integer factoryId);
	
	//按名称查询
//	@Select("select * from product where productName=#{productName}")
	public List<Product> listByProductName(String productName);
	
	//增加产品
	@Insert("insert into product values(null,#{productName},#{productImg},#{mechineId},#{factoryId})")
	public int saveProduct(Product product);

	//编辑产品
	@Update("update product set productName=#{productName},productImg=#{productImg},mechineId=#{mechineId},factoryId=#{factoryId} where productId=#{productId}")
	public int updateProduct(Product product);
	
	//删除产品
	@Delete("delete from product where productId=#{productId}")
	public int removeProduct(Product product);
	
	//查看该产品在在订单中的数量
	@Select("select count(*) from 'order' where productId=#{productId}")
	public int countProduct(Product product);
	
	//查询功能
	 @Select("select * from product where productName=#{productName}")
	 public List<Product> QueryProduct(String productName);
}
